#include<bits/stdc++.h>
using i64 = long long;

#define ull unsigned long long
using namespace std;

const int N = 1e6 + 10, INF = 0x3f3f3f3f;

i64 sumh = 0, sumx = 1, n, k, ans, m;
const int MOD = 998244353;
i64 a[N];



i64 qmi(i64 a, i64 b)
{
    i64 res = 1 % MOD;
    while (b) {
        if (b & 1) {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

inline i64 read()
{
    i64 x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

void solve()
{
    i64 x;
    n = read(), m = read();
    ans = 0;
    if ((n & 1) == 0 && (m & 1) == 0) {
        cout << 1 << '\n';
        return;
    }
    if ((n & 1) == 1 && (m & 1) == 1) {
        x = ((n - 1) + (m - 1));
        ans = (qmi(2, x)) % MOD;
        cout << ans << '\n';
        return;
    }
    if ((n & 1) == 0 && (m & 1) == 1) {
        x = (n - 1);
        //cout << "ans:" <<ans<< '\n';
        ans = (qmi(2, x)) % MOD;
        cout << ans << '\n';
        return;
    } else {
        x = (m - 1);
        ans = (qmi(2, x)) % MOD;
        cout << ans << '\n';
        return;
    }
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"(5
1 5
2 5
3 5
3 3
123 456
)");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    T = read();
    for (int i = 1;i <= T;i++) {
        solve();
    }
}